<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p:dialog xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:of="http://omnifaces.org/functions"
	xmlns:pe="http://primefaces.org/ui/extensions"
	modal="true" width="660" height="500" resizable="false" 
	widgetVar="dialogListCliente" id="listDialogCliente"
	appendToBody="true">

	<link type="text/css" rel="stylesheet" href="../../resources/css/style.css" />
	
	<f:facet name="header">
			<h:outputText value="Consultar Cliente"/>
	</f:facet>
	
	<h:form prependId="false" id="formlistCliente">
		<div style="margin-left:5%;">
			<h:panelGrid columns="8">
				<h:outputText value="Filtrar por:" />
								
				<p:inputText id="inputSearchFilterCodCliente" style="width:50px;" value="#{agendamentoBean.filterId}" maxlength="15" title="Código">
					<pe:keyFilter regEx="/[\d]/" />
				</p:inputText>
				<p:watermark value="Código" for="inputSearchFilterCodCliente"/>
				
				<p:inputText id="inputSearchFilterCliente" style="width:250px;" value="#{agendamentoBean.filter}" title="Nome" maxlength="100"/>
				<p:watermark value="Nome" for="inputSearchFilterCliente"/>
				
				<p:commandButton icon="ui-icon-search" style="height:24px;" id="searchButtonCliente" update="@form" actionListener="#{agendamentoBean.fillClienteByFilter}" title="Consultar"/>
				<p:commandButton icon="ui-icon-plus" style="height:24px;" actionListener="#{agendamentoBean.opendialogAddCliente}" title="Novo"/>
				<p:commandButton icon="ui-icon-check" title="Selecionar" actionListener="#{agendamentoBean.addCliente}" process="@this formlistCliente"  update="formlistCliente" style="height:24px;"/>
			</h:panelGrid>
		
			<div style="padding-top:10px;">
				<p:dataTable style="width:575px" var="cliente"
					value="#{agendamentoBean.clientes}" id="tableClientes"
					paginator="true" rows="10" paginatorPosition="bottom"
					selection="#{agendamentoBean.selectedCliente}" rowKey="#{cliente.id}"
					emptyMessage="Não há registros" selectionMode="single">  
					
					<p:ajax event="rowDblselect" listener="#{agendamentoBean.addCliente}"/>
					
					<p:column headerText="Código" style="width:100px;">  
				    	<h:outputText value="#{cliente.id}" />  
					</p:column>  
				 
					<p:column headerText="Nome">  
				    	<h:outputText value="#{of:abbreviate(cliente.nome, 65)}" />  
					</p:column>
					
					<p:column width="10">
						<p:commandButton icon="ui-icon-check" title="Selecionar" actionListener="#{agendamentoBean.addCliente(cliente.id)}" style="height:24px; width:24px;"/>
					</p:column>
					
			  	</p:dataTable>
			</div>
		</div>
	</h:form>
</p:dialog>